package entites;

import java.io.Serializable;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.hibernate.annotations.*;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;


@Entity
@Table(name = "personne" , uniqueConstraints =
			@UniqueConstraint(columnNames = "idPersonne"))

public class Personne implements Serializable
{
   /** Default value included to remove warning. Remove or modify at will. **/
   private static final long serialVersionUID = 1L;

   private Set<Destination> destinations = new HashSet<Destination>(0);
   @Id
   @GeneratedValue
   private Long idPersonne;

   @NotNull
   @Size(min = 1, max = 25)
   @Pattern(regexp = "[A-Za-z ]*")
   private String nom;
   
   @NotNull
   @Size(min = 1, max = 25)
   @Pattern(regexp = "[A-Za-z ]*")
   private String prenom;
   
  
   @NotNull
   private Date dateNaissane;
   
   @NotEmpty
   @Email
   private String email;
   
   @NotEmpty
   @NotNull
   private String ville;

   @NotNull
   @Size(min = 10, max = 12)
   @Digits(fraction = 0, integer = 12)
   @Column(name = "tel")
   private String tel;
   
   @NotNull
   @Size(min = 0)
   @Column(name = "compte")
   private String compte;
   
   public Date getDateNaissane() {
	return dateNaissane;
}

public void setDateNaissane(Date dateNaissane) {
	this.dateNaissane = dateNaissane;
}


public String getCompte() {
	return compte;
}

public void setCompte(String compte) {
	this.compte = compte;
}

public Long getIdPersonne() {
	return idPersonne;
}

public void setIdPersonne(Long idPersonne) {
	this.idPersonne = idPersonne;
}

public String getNom() {
	return nom;
}

public void setNom(String nom) {
	this.nom = nom;
}

public String getPrenom() {
	return prenom;
}

public void setPrenom(String prenom) {
	this.prenom = prenom;
}

public String getEmail() {
	return email;
}

public void setEmail(String email) {
	this.email = email;
}

public String getVille() {
	return ville;
}

public void setVille(String ville) {
	this.ville = ville;
}

public String getTel() {
	return tel;
}

public void setTel(String tel) {
	this.tel = tel;
}
   
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
		@JoinTable(name = "reservation", joinColumns = { 
		@JoinColumn(name = "idDestination", nullable = false, updatable = false) }, 
		inverseJoinColumns = { @JoinColumn(name = "idDestination", 
				nullable = false, updatable = false) })

public Set<Destination> getDestination() {
	return this.destinations;
}

public void setDestinatio(Set<Destination> destinations) {
	this.destinations = destinations;
}

}
